<%@page import="pro.syj.bean.Course"%>
<%@page import="pro.syj.dao.CourseDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>课程修改</title>
	<link rel='stylesheet' href='CSS/decorator1.css'>
</head>

<body>
	<h1>课程修改</h1>
	<hr>
	<%
	    String cid = request.getParameter("cid");
	    CourseDao coursedao = new CourseDao();
	    Course course = new Course();
	    course = coursedao.selectOne2(cid);
	%>
	<form action="managerUcourse-do.jsp" method="post" name="updateForm">
	
	<br>
	<div>
		<label>课程编号：</label>
		<input type="text" name="cid" value="<%=course.getCid() %>" required>
	</div><br>
	<div>
		<label>课程名：</label>
		<input type="text" name="cname" value="<%=course.getCname() %>" required>
	</div><br>
	<div>
		<label>课程类别：</label>
		<input type="text" name="category" value="<%=course.getCategory() %>" required>
	</div><br>
	<div>
		<label>平时占比：</label>
	   <input type="text" name="percent1" value="<%=course.getPercent1() %>" required>
	</div><br>
	<div>
		<label>期末占比：</label>
	   <input type="text" name="percent2" value="<%=course.getPercent2() %>" required>
	</div><br>
	<div>
		<button type="submit" onclick="return checkForm()">确认修改</button>
		<button type="reset">重置</button>
	</div><br>
	<div>
		<a href="javascript: window.history.go(-1)">  [返回上一级]</a>
		<a href="managerMain.jsp">[返回主界面]</a>
	</div>
	</form>
	
	<script type="text/javascript">
    function checkForm() {
        var percent1 = updateForm.percent1.value;
        var percent2 = updateForm.percent2.value;
        var p1 = parseFloat(percent1);
        var p2 = parseFloat(percent2);
        
        //alert(name + pwd + repwd);
        if (percent1 == "" || percent1 == null) {
            alert("修改值不能为空！");
            updateForm.percent1.focus();
            return false;
        }else if(percent2 == "" || percent2 == null) {
            alert("修改值不能为空！");
            updateForm.percent2.focus();
            return false;
        }else if( (p1 + p2) != 1.0 ){
        	alert("修改值不合法！");
        	updateForm.percent1.focus();
        	return false;
        }
        alert('正在提交......');
        return true;
    }
	</script>
</body>
</html>